<template>
    <!-- pages/mealpage/mealsuccess/index.wxml -->
    <view>
        <view class="paysucced">
            <image class="paysuccedimg" :src="imgUrl + 'paysucced.png'"></image>
        </view>
        <view class="see">恭喜您已成功核销套餐包内服务，</view>
        <view class="see">您可点击再次核销或是点击订单将查看订单详情</view>
        <view>
            <buttom @tap.native="toOrder" class="tohome">查看订单</buttom>
            <buttom @tap.native="toCancel" class="tomeal">继续核销</buttom>
        </view>
    </view>
</template>

<script>
// pages/mealpage/mealsuccess/index.js
const app = getApp(); // 引入app

export default {
    data() {
        return {
            imgUrl: app.globalData.imgUrl,
            //全局img路径
            id: ''
        };
    }
    /**
     * 生命周期函数--监听页面加载
     */,
    onLoad(options) {
        this.setData({
            id: options.id
        });
    },
    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady() {},
    /**
     * 生命周期函数--监听页面显示
     */
    onShow() {},
    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide() {},
    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload() {
        // wx.redirectTo({
        //   url: '/pages/mealpage/index',
        // })
    },
    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh() {},
    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom() {},
    /**
     * 用户点击右上角分享
     */
    onShareAppMessage() {},
    methods: {
        // 查看订单
        toOrder() {
            uni.redirectTo({
                url: '/pages/mealpage/details/index?id=' + this.id
            });
        },

        // 继续核销
        toCancel() {
            uni.scanCode({
                //扫描API
                success: function (res) {
                    if (res.path) {
                        uni.navigateTo({
                            url: '/pages/mealpage/cancel/index?id=' + res.path.split('=')[1]
                        });
                    } else {
                        uni.showToast({
                            title: '识别失败，请扫描正确的意约订单码',
                            icon: 'none',
                            duration: 1500
                        });
                    }
                },
                fail: function (res) {
                    // wx.showToast({
                    //   title: '识别失败，请扫描正确的意约订单码',
                    //   icon: 'none',
                    //   duration: 1500
                    // })
                }
            });
        }
    }
};
</script>
<style>
/* pages/mealpage/mealsuccess/index.wxss */
page > view:nth-child(1) {
    margin-top: 40rpx;
    text-align: center;
}

.see {
    margin-top: 20rpx;
    text-align: center;
    height: 34rpx;
    font-size: 24rpx;
    font-family: PingFangSC-Regular, PingFang SC;
    font-weight: 400;
    color: #999999;
    line-height: 34rpx;
}

.paysuccedimg {
    width: 340rpx;
    height: 186rpx;
}

.text {
    height: 44rpx;
    margin-top: 40rpx;
    font-size: 32rpx;
    font-family: PingFangSC-Medium, PingFang SC;
    font-weight: 500;
    color: #333333;
    line-height: 44rpx;
}

page > view > view:nth-child(4) {
    margin-top: 72rpx;
}

.tohome {
    display: inline-block;
    width: 180rpx;
    height: 60rpx;
    background: #fbfbfb;
    line-height: 60rpx;
    color: #ff8722;
    box-shadow: 0px 2px 4px 0px rgba(255, 128, 0, 0.26);
    border-radius: 15px;
    border: 1px solid #ff8722;
    margin-right: 75rpx;
}

.tomeal {
    display: inline-block;
    width: 180rpx;
    height: 60rpx;
    background: #ff8722;
    line-height: 60rpx;
    color: white;
    box-shadow: 0px 2px 4px 0px rgba(255, 128, 0, 0.26);
    border-radius: 15px;
    border: 1px solid #ff8722;
}
</style>
